/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "数学.h"

#include <thread>

using namespace std;


void f_线程_计算顶点集最大包围(vec3* v, uint32 num, vec3* 结果) {
	for (uint32 i = 0; i < num; ++i) {
		*(结果) = vec_Max(*(结果), v[i]);
	}
}

void f_线程_计算顶点集最小包围(vec3* v, uint32 num, vec3* 结果) {
	for (uint32 i = 0; i < num; ++i) {
		*(结果) = vec_Min(*(结果), v[i]);
	}
}


mat3X3 f_get坐标集包围盒(vec3* v, uint32 num) {
	mat3X3 box = { {100000000.0, 100000000.0, 100000000.0},   {-100000000.0, -100000000.0, -100000000.0},   {0.0, 0.0, 0.0} };

	thread t[2];
	t[0] = thread(f_线程_计算顶点集最小包围, v, num, &box.row0);
	t[1] = thread(f_线程_计算顶点集最大包围, v, num, &box.row1);
	
	t[0].join();
	t[1].join();

	box.row2 = vec_sub(box.row1, box.row0);

	return box;
}

float32 f_get坐标集包围球(vec3* v, uint32 num) {

	return float32();
}



